import 'package:flutter_test/flutter_test.dart';
import 'package:chewie_audio_ohos/chewie_audio_ohos.dart';
import 'package:video_player/video_player.dart';
import 'package:chewie_audio_ohos/src/chewie_player.dart';

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();
  group('ChewieAudio Tests', () {
    late VideoPlayerController videoPlayerController;
    late ChewieAudioController chewieAudioController;

    setUp(() async {
      videoPlayerController = VideoPlayerController.network(
          'https://www.w3schools.com/html/horse.mp3'
      );

      chewieAudioController = ChewieAudioController(
        videoPlayerController: videoPlayerController,
      );
    });

    tearDown(() async {
      videoPlayerController.dispose();
      chewieAudioController.dispose();
    });
    test('ChewieAudioController initialization', () async {
      expect(chewieAudioController.videoPlayerController, videoPlayerController);
      expect(chewieAudioController.autoPlay, false);
      expect(chewieAudioController.draggableProgressBar, true);
      expect(chewieAudioController.looping, false);
      expect(chewieAudioController.showControlsOnInitialize, true);
      expect(chewieAudioController.showControls, true);
      expect(chewieAudioController.allowMuting, true);
      expect(chewieAudioController.allowPlaybackSpeedChanging, true);
      expect(chewieAudioController.playbackSpeeds, [0.75, 1.0, 1.25, 1.75, 2.0]);
    });

    test('ChewieAudioController play and pause functionality', () async {
      await chewieAudioController.play();
      expect(chewieAudioController.isPlaying, isTrue);

      await chewieAudioController.pause();
      expect(chewieAudioController.isPlaying, isFalse);
    });
  });
}
